package org.jetlinks.pro.influx.device;

import org.jetlinks.core.device.DeviceRegistry;
import org.jetlinks.pro.device.service.data.DeviceDataStorageProperties;
import org.jetlinks.pro.influx.InfluxDBOperations;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnProperty(prefix = "influxdb", value = "enabled", havingValue = "true")
public class InfluxDeviceDataStoreConfiguration {


    @Bean
    public InfluxDBDeviceDataRowStoragePolicy influxTimeRowSeriesDeviceDataStorePolicy(DeviceRegistry registry,
                                                                                       InfluxDBOperations operations,
                                                                                       DeviceDataStorageProperties properties) {
        return new InfluxDBDeviceDataRowStoragePolicy(
            registry,
            operations,
            properties
        );
    }

    @Bean
    public InfluxDBDeviceDataColumnStoragePolicy influxTimeSeriesDeviceDataColumnStorePolicy(DeviceRegistry registry,
                                                                                             InfluxDBOperations operations,
                                                                                             DeviceDataStorageProperties properties) {
        return new InfluxDBDeviceDataColumnStoragePolicy(
            registry,
            operations,
            properties
        );
    }


}